package test.javaforever.infinity.generator;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;
import org.light.domain.Domain;
import org.light.domain.Field;
import org.light.domain.ManyToMany;
import org.light.generator.PrivilegedFacadesUrlGenerator;

import junit.framework.TestCase;

public class PrivilegedFacadesUrlGeneratorTest extends TestCase{
	@Test
	public void testGenerateMtmUrls() throws Exception{
		String dbPrefix = "my_";
		
		Domain master = new Domain();
		master.setStandardName("Person");
		master.setPlural("People");
		master.setDomainId(new Field("id","Long"));
		master.setDomainName(new Field("name","String"));
		master.setActive(new Field("active","Boolean"));
		master.setDbPrefix(dbPrefix);
		
		Domain slave= new Domain();
		slave.setStandardName("Permission");
		slave.setDomainId(new Field("id","Long"));
		slave.setDomainName(new Field("permissionName","String"));
		slave.setActive(new Field("active","Boolean"));
		slave.setDbPrefix(dbPrefix);
		
		ManyToMany mtm = new ManyToMany(master,slave);
		List<ManyToMany> mList = new ArrayList<ManyToMany>();
		mList.add(mtm);
		List<String> data = PrivilegedFacadesUrlGenerator.generatePrivilegedFacadesByMtms(mList, "observer");
		
		for (String url:data) {
			System.out.println("JerryTest:"+url);
		}
		System.out.println();

		List<String> data2 = PrivilegedFacadesUrlGenerator.generatePrivilegedFacadesByMtms(mList, "admin");
		
		for (String url:data2) {
			System.out.println("JerryTest2:"+url);
		}
		System.out.println();
		
		List<Domain> dList = new ArrayList<Domain>();
		dList.add(master);
		dList.add(slave);
		
		List<String> data3 = PrivilegedFacadesUrlGenerator.generatePrivilegedFacadesByDomains(dList, "observer");
		
		for (String url:data3) {
			System.out.println("JerryTest3:"+url);
		}
		System.out.println();
		
		List<String> data4 = PrivilegedFacadesUrlGenerator.generatePrivilegedFacadesByDomains(dList, "user");
		
		for (String url:data4) {
			System.out.println("JerryTest4:"+url);
		}
		
	}
}
